home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.2 Applications 1996 May / SGI IRIX 6.2 Applications 1996 May.iso / dist / impr_dev.idb / usr / impressario / src / gui_models / laserjetPJL / resource.c.z / resource.c
C/C++ Source or Header  |  1996-05-06  |  3KB  |  88 lines

  1. /**************************************************************************
  2.  *
  3.  *                Copyright (c) 1993 Silicon Graphics, Inc.
  4.  *
  5.  * Permission to use, copy, modify, distribute, and sell this software and
  6.  * its documentation for any purpose is hereby granted without fee, provided
  7.  * that (i) the above copyright notices and this permission notice appear in
  8.  * all copies of the software and related documentation, and (ii) the name of
  9.  * Silicon Graphics may not be used in any advertising or publicity relating
  10.  * to the software without the specific, prior written permission of Silicon
  11.  * Graphics.
  12.  * 
  13.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  14.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  15.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  16.  *
  17.  * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  18.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  19.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
  20.  * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
  21.  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * SILICON GRAPHICS RESERVES THE RIGHT TO CHANGE FUTURE VERSIONS OF THIS
  24.  * SOFTWARE IN ANY MANNER AND AT ANY TIME WITHOUT PRIOR NOTICE.
  25.  *
  26.  **************************************************************************
  27.  *
  28.  * File: ps_opts.c
  29.  *
  30.  * Note to Developer: Modify this file if you are adding or removing
  31.  *      PostScript file options.
  32.  *
  33.  * Description: UI and handling routines for PostScript file options. 
  34.  *      Options that fall into this category are those that pertain to
  35.  *      PostScript files.
  36.  *
  37.  **************************************************************************/
  38.  
  39. /*
  40.  * resource.c
  41.  *
  42.  * Simplified ways to get resources
  43.  */
  44.  
  45. #include <X11/Intrinsic.h>
  46. #include <X11/StringDefs.h>
  47. #include <Xm/Xm.h>
  48. #include "xutil.h"
  49.  
  50. /*
  51.  *  char *
  52.  *  GetResourceString(Widget w, char *name, char *class, char *def)
  53.  *
  54.  *  Description:
  55.  *      Get a resource string for a widget.
  56.  *
  57.  *  Parameters:
  58.  *      w      Widget to get resource for
  59.  *      name   resource name
  60.  *      class  resource class
  61.  *      def    default value
  62.  *
  63.  *  Returns:
  64.  *      String value of the resource.  Note that if def is non-NULL,
  65.  *      this will always be valid (in other words, if what you pass in
  66.  *      as def is guaranteed to be valid, you don't have to check the
  67.  *      return value of this function)
  68.  */
  69.  
  70. char *
  71. GetResourceString(Widget w, char *name, char *class, char *def)
  72. {
  73.     XtResource res;
  74.     char *str;
  75.  
  76.     res.resource_name = name;
  77.     res.resource_class = class;
  78.     res.resource_type = XtRString;
  79.     res.resource_size = sizeof(char *);
  80.     res.resource_offset = 0;
  81.     res.default_type = XtRString;
  82.     res.default_addr = def;
  83.  
  84.     XtGetApplicationResources(w, &str, &res, 1, NULL, 0);
  85.  
  86.     return str ? str : def;
  87. }
  88.